﻿using System.IO;
using System.Linq;
using System.Reflection;
using NDesk.Options;
using System;
using NETDeob.Core.Engine;

namespace NETDeob
{
    internal static class Program
    {
        private static void Main(string[] args)
        {
            // Show Program Info
            Console.WriteLine(String.Concat("NETDeob 0.4.0.0", "\n"));

            if (args.Length == 0)
                return;

            // Argument Parsing
            var optionSet = new OptionSet
            {
                {"v=", (Int32 level) => { Settings.Verbosity = level; }},
                {"t=", (String target) => { Settings.Target = target; }}
            };
            optionSet.Parse(args);

            if (String.IsNullOrEmpty(Settings.Target) || !File.Exists(Settings.Target))
                return;

            // Deobfuscate
            var deobfuscator = new Core.Deobfuscator();
            deobfuscator.Deobfuscate();

            // Output
            Logger.Log(String.Concat("\n","Deobfuscation Complete"), 0);
            Logger.Log("Press Any Key To Exit...",0);

            // Noob Help
            Console.ReadKey();
        }
    }
}